<?php
/**
 * $Id: hooks.php 142 2014-11-13 07:59:04Z hitesh $
 * 
 * This file can not be redistributed to anyone without the permission of Giga Promoters
 * Copyright 2005 - 2008, Giga Promoters
 * 						  608 Aggarwal Cyber Plaza
 *						  Netaji Subhash Place, Delhi - 110034
 *						  www.gigapromoters.com
 * 
 *
 * This is parent of parent class of a controller and should not be edited ever without permission.
 * @version 			$Rev: 142 $
 * @lastModifiedBy		$LastChangedBy: hitesh $
 * @lastChanged			$Date: 2014-11-13 13:29:04 +0530 (Thu, 13 Nov 2014) $
 * @copyright 			Giga Promoters (www.gigapromoters.com)
 * 
 */

// @todo make a new config for it in backend
Configure::write('Modules.editorEnabled', false);

function ModulesBeforeFilterHook(AppController $controller)
{
	$controller->helpers[] = "Modules.Section";
	
	$isAdmin = $controller->_isAdmin();
	$visitingFrontend = !isset($controller->params['prefix']);
	$modulEditorMode = $controller->Session->read('Module.moduleEditor');
	//enable editor mode if admin is on frontend.
	if($isAdmin && $visitingFrontend && $modulEditorMode === true)
	{
		Configure::write('Modules.moduleEditorMode',true);
	}
}


function ModulesBuildAdminMenuHook($backend)
{
	$backend->addMenuItem(ADMIN_APPEARANCE, __('Modules'),"/modules/modules/index");
}
?>